package com.android.mediaremote;

import java.io.File;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class FileAdapter extends BaseAdapter 
{
	private List<File> files;
	private LayoutInflater inflater;
	
	public FileAdapter(Context context,List<File> files)
	{
		inflater = LayoutInflater.from(context);
		this.files=files;
	}
	
	@Override
	public int getCount() 
	{
		return this.files.size();
	}

	@Override
	public Object getItem(int arg0) 
	{
		return this.files.get(arg0);
	}

	@Override
	public long getItemId(int arg0) 
	{
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) 
	{
		TextView file_path;
		if(convertView == null) 
		{
			convertView = inflater.inflate(R.layout.fileliste, null);
			file_path = (TextView)convertView.findViewById(R.id.file_path);
			convertView.setTag(file_path);
		} 
		else 
		{
			file_path = (TextView) convertView.getTag();
		}
	
		file_path.setText(this.files.get(position).getName());
	
		return convertView;
	}

}
